<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box1{
            width: 100px;
            height: 100px;
            background: red;
            display: block;
        }
        .box2{
            width: 100px;
            height: 100px;
            background: blue;
            display: none;
        }
        .box3{
            width: 100px;
            height: 100px;
            background: yellow;
            display: none;
        }

    </style>
</head>
<body>
    <div class="contaner1">
        <button>按钮一</button>
        <button>按钮二</button>
        <button>按钮三</button>
        <div class="box1"></div><div class="box2"></div>
        <div class="box3"></div>
    </div>
    <script>
        // 面向对象：简单的程序 面向过程；
        // 面向对象：需求复杂(属性方法比较多) 涉及对象较多 。
        // 需求一：写一个选项卡；

        var btns = document.querySelectorAll("button");
        var divs = document.querySelectorAll(".contaner1 div");
        btns.forEach((btn,key)=>{
            btn.onclick = function(){
                divs.forEach((div,index)=>{
                    if(key==index){
                        div.style.display = "block";
                    }else{
                        div.style.display = "none";
                    }
                })
            }
        })
        



    </script>
</body>
</html>